package com.elite.groovy.callback

import com.elite.groovy.util.EliteBean
import net.sf.json.JSONArray
import net.sf.json.JSONObject
import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
/**
 * @projectName: Groovy
 * @package: com.elite.groovy.callback
 * @className: getRight
 * @description: 网聊广告配置获取API
 * @author: LiJT
 * @date: 2023-10-27 11:13
 * @version: 1.0
 */

public class getRight implements ServiceBackInvoke {

    private static final Log log = LogFactory.getLog(getRight.class);

    public String doCallBack(EliteBean eliteBean, HttpServletRequest request, HttpServletResponse response) {
        log.debug("获取广告区域信息...");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json;charset=UTF-8");

        String DBS = "dataSource";

        String getRightdataSQL = "Select Orderid, Questionname, Content From Chat_Rightdata_Question Where Type = '1' Order By Orderid Limit 6";
        List getRightdataResult = eliteBean.chaxun_sql(getRightdataSQL, DBS);

        JSONObject questions = new JSONObject();
        JSONArray RightdataArray = JSONArray.fromObject(getRightdataResult)
        questions.put("status", "success");
        questions.put("data", RightdataArray);

        log.debug("获取广告区域信息：" + questions.toString());
        return questions;
    }
}